<?php
$this->pageTitle=Yii::app()->name . ' - Buchungsuebersicht';
$this->breadcrumbs=array(
	'Buchungsuebersicht',
);

	$email = "'".Yii::app()->user->name."'";
	$kunde = Kunde::model()->find("email = $email");
	$kundenId = $kunde->kundenID;
	$buchungenIDArray = Buchung::model()->findAll("kundenId = $kundenId");
	
		
	foreach($buchungenIDArray as $buchungID){
		$date = formatDate($buchungID->bestellzeit);
		echo "<div style=\"background:#6CAACE;\"><h2 style=\"color:#FFFFFF;\">Buchung vom $date</h2></div>";
		$buchungId = $buchungID->buchungsID;
		$auftrag = Auftrag::model()->find("buchung = $buchungID->buchungsID ");
	

		$formular = "";
		$formular.="<table style=\"background:#EFF4FA;\">";
		$formular.="<tr>";
		$formular.="<th width=\"50px\">Startort:</th>";
		$formular.="<td>".$auftrag->startort."</td>";
		$formular.="</tr>";
		$formular.="<th>Endort:</th>";
		$formular.="<td>".$auftrag->endort."</td>";
		$formular.="</tr>";
		$formular.="<tr>";
		$formular.="<th>Datum:</th>";
		$formular.="<td>".formatDate($auftrag->datum)."</td>";
		$formular.="</tr>";
		$formular.="<tr>";
		$formular.="<th>Zeit:</th>";
		$formular.="<td>".$auftrag->zeit."</td>";
		$formular.="</tr>";
		$formular.="<tr>";
		$formular.="<th>Dauer:</th>";
		$formular.="<td>".$auftrag->dauer."</td>";
		$formular.="</tr>";
		$formular.="</table>";
		echo $formular;

	}
		
	function formatDate($date){
		$year = substr($date, 0, 4);
		$month = substr($date, 4, 2);
		$day = substr($date, 6, 2);
		return $day.".".$month.".".$year;
	}

?>